<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="__STATIC__/js/jquery.js"></script>
    <script src="__STATIC__/layui/layui.js"></script>
    <script src="__STATIC__/bootstrap-table/js/bootstrap-table.js"></script>
    <script src="__STATIC__/bootstrap-table/js/bootstrap-table-zh-CN.min.js"></script>
    <script src="__STATIC__/bootstrap-table/js/dropdown.js"></script>
    <link rel="stylesheet" href="__STATIC__/bootstrap-table/css/bootstrap-table.min.css">
    <link rel="stylesheet" href="__STATIC__/bootstrap-table/css/bootstrap.css">
    <script type="text/javascript" src="__STATIC__/x-admin/js/xadmin.js"></script>
    <link rel="stylesheet" href="__STATIC__/x-admin/css/font.css">
    <link rel="stylesheet" href="__STATIC__/x-admin/css/xadmin.css">

    <link type="text/css" rel="stylesheet" href="__STATIC__/uploads/css/fileinput.css"/>
    <script type="text/javascript" src="__STATIC__/uploads/js/fileinput.js"></script>
    <script type="text/javascript" src="__STATIC__/uploads/js/fileinput_locale_zh.js"></script>
    <link type="text/css" rel="stylesheet" href="__STATIC__/uploads/css/bootstrap.min.css"/>


</head>
<body>
<div class="x-nav">
      <span class="layui-breadcrumb">
        <a href="#">业务管理</a>
        <a href="#">客户管理</a>
        <a href="#">培训机构</a>
        <a href="#">相关评论</a>
        <a href="#">添加评论</a>
      </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
        <i class="layui-icon" style="line-height:30px">ဂ</i></a>
</div>
<form class="layui-form" action="" onsubmit="return false" id="comment" style="">
    <br>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
        <i class="layui-icon" style="line-height:30px">ဂ</i></a>
    <input type="text" value="{$data.id}" hidden name="id">
    <div class="layui-form-item">
        <label class="layui-form-label">发表人</label>
        <div class="layui-input-block">
            <input type="text" name="name" placeholder="请输入姓名" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">内容</label>
        <div class="layui-input-block">
            <input type="text" name="content"  placeholder="请输入想要发表的内容" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">评分</label>
        <div class="layui-input-block">
            <input type="radio" name="score" value="1" title="1">
            <input type="radio" name="score" value="2" title="2">
            <input type="radio" name="score" value="3" title="3">
            <input type="radio" name="score" value="4" title="4">
            <input type="radio" name="score" value="5" title="5" checked>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">上传图片</label>
        <div class="layui-input-block" >
            <input type="file" name="file" id="uploads" multiple class="file-loading" />
            <input type="text" name="image" id="img" value="" hidden>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" id="add">立即添加</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>
</body>
</html>
<script>
    $("#uploads").fileinput({
        language: 'zh', //设置语言
        uploadUrl: "{:url('/common/img')}", //上传的地址
        uploadExtraData: {path:'/public/uploads/train/img'},
        allowedFileExtensions: ['jpg', 'gif', 'png'],//接收的文件后缀
        showUpload: true, //是否显示上传按钮
        showCaption: false,//是否显示标题
        browseClass: "btn btn-primary", //按钮样式
        //dropZoneEnabled: false,//是否显示拖拽区域
        minImageWidth: 200, //图片的最小宽度
        minImageHeight: 200,//图片的最小高度
        maxImageWidth: 200,//图片的最大宽度
        maxImageHeight: 200,//图片的最大高度
        //maxFileSize: 0,//单位为kb，如果为0表示不限制文件大小
        //minFileCount: 0,
        maxFileCount: 4, //表示允许同时上传的最大文件个数
        enctype: 'multipart/form-data',
        validateInitialCount:true,
        previewFileIcon: "<i class='glyphicon glyphicon-king'></i>",
        msgFilesTooMany: "选择上传的文件数量({n}) 超过允许的最大数值{m}！"
    }).on("fileuploaded", function (event, data, previewId, index) {
            var image = $("#img").val();
            $("#img").val(image+","+data.response.img)
    });

</script>
<script>
    $("#add").click(function () {
        $.ajax({
            url:"{:url('/train/trainCommentAdd')}",
            data:$("#comment").serialize(),
            type:"post",
            dataType:"json",
            success:function(res){
                if(res.code){
                    layer.msg(res.msg,{icon:1,time:2000},function(){
                        window.location.reload();
                    });
                    return;
                }else{
                    layer.msg(res.msg,{icon:5,time:2000});
                    return;
                }
            }
        })
    })
</script>